//
//  CCOnlyPromptTextHUD.m
//  MXApp
//
//  Created by ChenChao on 15/3/30.
//  Copyright (c) 2015年 YingXiang. All rights reserved.
//

#import "CCOnlyPromptTextHUD.h"
#import "AppDelegate.h"

static CCOnlyPromptTextHUD* kOnlyPromptTextHUD = nil;
static CGFloat kDefaultPromptTime = 2.0f;

@implementation CCOnlyPromptTextHUD

+ (void)showDefaultPromptTextHUD:(NSString*)text {
  [self showDefaultPromptTextHUD:text afterDelay:kDefaultPromptTime];
}

+ (void)showDefaultPromptTextHUD:(NSString*)text afterDelay:(NSTimeInterval)delay {
  if (kOnlyPromptTextHUD == nil) {
    UIWindow* window = [[AppDelegate sharedInstance] window];

    kOnlyPromptTextHUD = [[CCOnlyPromptTextHUD alloc] initWithView:window];
    [window addSubview:kOnlyPromptTextHUD];
    [kOnlyPromptTextHUD showAnimated:YES];
    kOnlyPromptTextHUD.userInteractionEnabled = NO;
    kOnlyPromptTextHUD.bezelView.color = [UIColor blackColor];
    kOnlyPromptTextHUD.contentColor = [UIColor blackColor];
    kOnlyPromptTextHUD.mode = MBProgressHUDModeText;
    kOnlyPromptTextHUD.removeFromSuperViewOnHide = YES;
    kOnlyPromptTextHUD.delegate = kOnlyPromptTextHUD;
  }
  kOnlyPromptTextHUD.detailsLabel.text = text;
  [kOnlyPromptTextHUD hideAnimated:YES afterDelay:delay];
}

#pragma mark - MBProgressHUDDelegate
- (void)hudWasHidden:(MBProgressHUD*)hud {
  kOnlyPromptTextHUD.delegate = nil;
  kOnlyPromptTextHUD = nil;
}

@end
